package com.project.springboot.controller;

import com.gitee.yongzhuzl.commonutil.util.result.ResponseResult;
import com.project.springboot.vo.Lock4jUserReqVo;
import com.project.springboot.vo.Lock4jUserResVo;
import com.project.springboot.dataobject.Lock4jUser;
import com.project.springboot.page.PageResult;
import com.project.springboot.service.lock4j.Lock4jUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * description: Lock4j用户web
 * @author 朱正磊
 * @date 2023-08-08 23:28:10
 */
@RestController
@RequestMapping("/lock4jUser")
public class UserController {

    @Resource
    private Lock4jUserService lock4jUserService;

    /**
     * description: 测试基于Redisson的Lock4j分布式锁框架
     * @author 朱正磊
     * @date 2023-08-08 23:40:29
     * @param lock4jUser 用户实体类
     * @return 返回响应对象
     */
    @PostMapping("/doLock4jTest")
    public ResponseResult<Void> doLock4jTest(@RequestBody Lock4jUser lock4jUser) {
        lock4jUserService.doLock4jTest(lock4jUser);
        return ResponseResult.buildSuccess(null);
    }

    /**
     * description: 测试分页
     * @author 朱正磊
     * @date 2023-08-09 23:19:44
     * @return 返回响应对象
     */
    @GetMapping("/userPage")
    public ResponseResult<PageResult<Lock4jUserResVo>> userPage(Lock4jUserReqVo lock4jUserReqVo) {
        PageResult<Lock4jUserResVo> pageResult = lock4jUserService.userPage(lock4jUserReqVo);
        return ResponseResult.buildSuccess(pageResult);
    }

}
